function w = svm_train(data,class)

c = find(data(:,5)==class);
nc_data = find(not(data(:,5)==class));

c_ind = ceil(size(c,1)*rand(uint64(ceil(size(c,1)/2)),1));

nc_ind = ceil(size(nc_data,1)*rand(uint64(ceil(size(c,1)/2)),1));
unique(data(c(c_ind),5))
unique(data(nc_data(nc_ind),5))
pause
%data(c(c_ind),6:end) = data(c(c_ind),6:end)./repmat(max(data(:,6:end)),size(data(c(c_ind),:),1),1);

%data(nc_data(nc_ind),6:end) = data(nc_data(nc_ind),6:end)./repmat(max(data(:,6:end)),size(data(nc_data(nc_ind),:),1),1);

%data(c(c_ind),6:end) = data(c(c_ind),6:end) - repmat(mean(data(:,6:end)),size(data(c(c_ind),6:end),1),1);

%data(nc_data(nc_ind),6:end) = data(nc_data(nc_ind),6:end) - repmat(mean(data(:,6:end)),size(data(nc_data(nc_ind),6:end),1),1);

w = ones(1,size(data(1,6:end),2))./size(data(1,6:end),2);

alpha = 1/sqrt(size(c_ind,1)+size(nc_ind,1));

lambda = 0.05;

%SVMStruct = svmtrain([data(c(c_ind),6:end);data(nc_data(nc_ind),6:end)], ones(2*size(c_ind,1),1));
for j =1:100
for i =1:size(c_ind,1)
        f = data(c(c_ind(i)),6:end);
        f(end) = 1;
        yt = sum(w.*f);
        
        if(yt > 1)
            w = w -(alpha*lambda)*w;
        else
            w = w -(alpha*lambda)*w + (alpha)*f;
        end
        
        
        f = data(nc_data(nc_ind(i)),6:end);
        f(end) = 1;
        yn = sum(w.*f);
        
        if(yn < -1)
            w = w -(alpha*lambda)*w;
        else
            w = w -(alpha*lambda)*w + (alpha*-1)*f;
        end
              
     
end
end